home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ASMVLA01.ZIP / ASM3.ASM < prev    next >
Assembly Source File  |  1993-04-13  |  2KB  |  85 lines

  1. ;   VERY, VERY simple ANSI/text viewer
  2. ;
  3. ;   Coded by Draeden [VLA]
  4. ;
  5.  
  6.     DOSSEG
  7.     .MODEL SMALL
  8.     .STACK 200h
  9.     .CODE
  10.     Ideal
  11.  
  12. ;===- Data -===
  13.  
  14. BufferSeg   dw  0
  15.  
  16. ErrMsgOpen  db  "Error opening `"
  17. FileName    db  "ANSI.TXT",0,8,"'$"     ;8 is a delete character
  18.                                         ;0 is required for filename 
  19.                                         ;(displays a space)
  20. FileLength dw 0
  21.  
  22. ;===- Subroutines -===
  23.  
  24. PROC DisplayFile NEAR
  25.     push    ds
  26.  
  27.     mov     ax,cs
  28.     mov     ds,ax
  29.     mov     ax,3d00h    ;open file (ah=3dh)
  30.     mov     dx,offset FileName
  31.     int     21h
  32.     jc      OpenError
  33.     mov     bx,ax       ;move the file handle into bx
  34.  
  35.     mov     ds,[BufferSeg]
  36.     mov     dx,0            ;load to [BufferSeg]:0000
  37.     mov     ah,3fh
  38.     mov     cx,0FFFFh       ;try to read an entire segments worth
  39.     int     21h
  40.  
  41.     mov     [cs:FileLength],ax
  42.  
  43.     mov     ah,3eh
  44.     int     21h             ;close the file
  45.  
  46.     cld
  47.     mov     si,0
  48.     mov     cx,[cs:FileLength]
  49. PrintLoop:
  50.     mov     ah,2
  51.     lodsb
  52.     mov     dl,al
  53.     int     21h         ;print a character
  54.  
  55.     dec     cx
  56.     jne     PrintLoop
  57.     
  58.     pop     ds
  59.     ret
  60.  
  61. OpenError:
  62.     mov     ah,9
  63.     mov     dx,offset ErrMsgOpen
  64.     int     21h
  65.  
  66.     pop     ds
  67.     ret
  68. ENDP DisplayFile
  69.  
  70. ;===- Main Program -===
  71.  
  72. START:
  73.     mov     ax,cs
  74.     mov     ds,ax
  75.     mov     bx,ss
  76.     add     bx,200h/10h     ;get past the end of the file
  77.     mov     [BufferSeg],bx  ;store the buffer segment
  78.  
  79.     call    DisplayFile
  80.  
  81.     mov     ax,4c00h
  82.     int     21h
  83. END START
  84.  
  85.